package com.jc.oss.adapter;

import com.jc.oss.Entity.FileInfo;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

/**
 * @Description: 文件存储适配器
 * @Author: ASL_ly
 * @Package: com.jc.oss.service
 * @Project: jc-club
 * @Date: 2024/10/26  14:12
 */
public interface StorageAdapter {
    /**
     * 创建bucket桶
     * @param bucket
     * @throws Exception
     */
    public void createBucket(String bucket);
    /**
     * 上传文件
     * @param uploadFile
     * @param bucket
     * @param objectName
     * @throws Exception
     */
    public void uploadFile(MultipartFile uploadFile, String bucket, String objectName) ;

    /**
     * 列出所有的bucket
     * @return
     * @throws Exception
     */
    public List<String> getAllBucket() ;


    /**
     * 列出bucket下的所有文件
     * @param bucket
     * @return
     * @throws Exception
     */
    public List<FileInfo> listAllFile(String bucket) ;
    /**
     * 下载文件
     * @param bucket
     * @param objectName
     * @return
     * @throws Exception
     */
    public InputStream downLoad(String bucket, String objectName);

    /**
     * 删除桶
     * @param bucket
     * @throws Exception
     */
    public void deleteBucket(String bucket);
    /**
     * 删除文件
     * @param bucket
     * @param objectName
     * @throws Exception
     */
    public void deleteObject(String bucket, String objectName);

    /**
     * 获取文件路径
     * @param bucketName
     * @param objectName
     * @return
     */
    String getUrl(String bucketName, String objectName);
}

